package com.application.Tree;

import java.util.List;
import java.util.Map;

import com.application.Activity.R;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.SimpleAdapter;
import android.widget.TextView;

public class SpinerEmoticonAdapter extends ArrayAdapter<Emoticon>{
    
    private Context MyContext;
    private Emoticon[] data;

	public SpinerEmoticonAdapter(Context context, int textViewResourceId,
			Emoticon[] objects) {
		super(context, textViewResourceId, objects);
		this.MyContext = context;
		this.data = objects;
	}
	
	public Emoticon getItem(int position) {
		return data[position];
	}
	
	@Override
    public View getDropDownView(int position, View convertView,ViewGroup parent) {
        return getCustomView(position, convertView, parent);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
    	Log.d("Spinner", "MyDialog-MyAdapter-getView.." + data[position].name);
    	LayoutInflater inflater= (LayoutInflater)MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row=inflater.inflate(R.layout.spiner_view, parent, false); 
        ImageView icon=(ImageView)row.findViewById(R.id.image);
        icon.setImageResource(data[1].emoticon);
        return row;
    }

    public View getCustomView(int position, View convertView, ViewGroup parent) {
    	
        LayoutInflater inflater = (LayoutInflater) MyContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row=inflater.inflate(R.layout.spiner_view, parent, false);
        TextView label=(TextView)row.findViewById(R.id.company);
        label.setText(data[position].name);

        TextView sub=(TextView)row.findViewById(R.id.sub);
        sub.setText(data[position].subs + "  " + "'"+data[position].symbols+"'");

        ImageView icon=(ImageView)row.findViewById(R.id.image);
        icon.setImageResource(data[position].emoticon);

        return row;
    }

}


